package com.sy.controller;

import com.sy.bean.Receipt;
import com.sy.bean.management.ReceiptQuery;
import com.sy.common.bean.PageBean;
import com.sy.common.bean.ResultBean;
import com.sy.common.controller.BaseController;
import com.sy.common.utils.BeanOfMap;
import com.sy.service.ReceiptService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@Api(tags = "付款单管理")
@RequestMapping("/api")
public class ReceiptController extends BaseController {
    @Autowired
    ReceiptService receiptService;

    @ApiOperation("保存付款单")
    @PostMapping("/receipt")
    public ResultBean save(@RequestBody Receipt receipt) {
        int rs = receiptService.save(receipt);
        return gotoResult(rs, "保存");
    }
    @ApiOperation("审核付款单")
    @PutMapping("/receipt/audit")
    public ResultBean audit(@RequestParam(value = "id", required = true)int id){
        int rs = receiptService.audit(id);
        return gotoResult(rs,"审核");
    }

    @ApiOperation("付款单列表")
    @PostMapping("/receipt/list")
    public ResultBean list(@RequestBody ReceiptQuery rs){
        PageBean pageBean = receiptService.query(BeanOfMap.bom(rs));
        return success("付款单列表",pageBean);
    }
}
